﻿HotelName@model RBS.Core.Model.D_Order
@{
    ViewBag.Title = "订单";
    Layout = "~/Views/Shared/_Layout.cshtml"; 
}

<link href="~/Scripts/datepicker/skin/WdatePicker.css" rel="stylesheet" />
<script src="~/Scripts/datepicker/lang/zh-cn.js"></script>
<script src="~/Scripts/datepicker/WdatePicker.js"></script>

@using (Html.BeginForm("Order","Store",FormMethod.Post,new{id="OrderForm"}))
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)
    @Html.HiddenFor(model => model.H_Id) 
    @Html.HiddenFor(model => model.Id) 

    <div id="content">
        <div class="h1a">本地商户</div>
          @{
            var hotel = new RBS.Core.BLL.Hotel.H_Hotels().GetModelByCache(Model.H_Id); 
              @Html.Partial("_HotelHead",hotel);
            } 
        <div id="mainContent1">
            <div class="tab-content destineorder">
                <dl>
                    <dt><b>*</b>预订吃饭日期</dt>
                    <dd>
                        @Html.TextBoxFor(model => model.ReserveDate, null, new { @class = "input small w120", onfocus = "WdatePicker({dateFmt:'yyyy年MM月dd日',minDate:'%y-%M-{%d}'})" })
                         @{ 
                              var times= new SelectList(new List<SelectListItem>
                                            {
                                                    new SelectListItem {Text = "11时00分", Value = "11时00分"},
                                                    new SelectListItem {Text = "11时30分", Value = "11时30分"},
                                                    new SelectListItem {Text = "12时00分", Value = "12时00分"},
                                                    new SelectListItem {Text = "12时30分", Value = "12时30分"},
                                                    new SelectListItem {Text = "13时00分", Value = "13时00分"},
                                                    new SelectListItem {Text = "13时30分", Value = "13时30分"},
                                                    new SelectListItem {Text = "14时00分", Value = "14时00分"},
                                                    new SelectListItem {Text = "14时30分", Value = "14时30分"},
                                                    new SelectListItem {Text = "15时00分", Value = "15时00分"},
                                                    new SelectListItem {Text = "15时30分", Value = "15时30分"},
                                                    new SelectListItem {Text = "16时00分", Value = "16时00分"},
                                                    new SelectListItem {Text = "16时30分", Value = "16时30分"},
                                                    new SelectListItem {Text = "17时00分", Value = "17时00分"},
                                                    new SelectListItem {Text = "17时30分", Value = "17时30分"},
                                                    new SelectListItem {Text = "18时00分", Value = "18时00分"},
                                                    new SelectListItem {Text = "18时30分", Value = "18时30分"},
                                                    new SelectListItem {Text = "19时00分", Value = "19时00分"},
                                                    new SelectListItem {Text = "19时30分", Value = "19时30分"}
                                            }, "Value", "Text", Model.ReserveTime); 
                        } 
                        @Html.DropDownListFor(model => model.ReserveTime,times,new{datatype="time",errormsg="吃饭时间不能小于当前时间",nullmsg="请选择时间"}) 
                    </dd>
                </dl>
                <dl>
                    <dt><b>*</b>就餐人数</dt>
                    <dd>
                        @Html.TextBoxFor(model => model.DineNum, null, new { @class = "input normal w100", datatype = "n", value = "" })
                        <span class="Validform_checktip">*就餐人数</span>
                    </dd>
                </dl>
                <dl>
                    <dt><b>*</b>餐位情况</dt>
                    <dd class="ltable">
                        <label for="Dinecondition">大厅</label>
                        @Html.RadioButton("Dinecondition", "大厅")
                        <label for="Dinecondition">包间</label>
                        @Html.RadioButton("Dinecondition", "包间")
                    </dd>
                </dl>
                <dl>
                    <dt><b>*</b>桌位</dt>
                    <dd>
                        @Html.HiddenFor(model => model.DineTable)
                         @Html.Hidden("OldDineTable",null,new{value=@ViewBag.DineTable})
                        <script type="text/template" id="SeatTemplate">
                            <li id="li{{Id}}" name="{{Name}}">
                                <p>
                                    <a href="{{Picture}}" target="_blank">
                                        <img src="@(RBS.Common.ConfigHelper.GetConfigString("hotelWeb")){{Picture}}" /></a>
                                </p>
                                <h4>
                                    <input type="radio" id="seat{{Id}}" name="seat" value="{{Id}}" onclick="selectTable('{{Id}}', '{{Name}}')"  {{s}} />{{Name}}</h4>
                            </li>
                        </script>

                        <ul id="seatUl"></ul>
                        <span id="selectTable" class="Validform_checktip"></span>
                    </dd>
                </dl>

                <dl>
                    <dt><b>*</b>联系人</dt>
                    <dd>

                        @Html.TextBoxFor(model => model.ContactUser, null, new { @class = "input normal w100" })
                        <span class="Validform_checktip">*联系人</span>

                    </dd>
                </dl>
                <dl>
                    <dt><b>*</b>用户手机</dt>
                    <dd>

                        @Html.TextBoxFor(model => model.ContactMobile, null, new { @class = "input normal w100" })
                        <span class="Validform_checktip">*用户手机</span>

                    </dd>
                </dl>
                <dl>
                    <dt>订单备注</dt>
                    <dd>

                        @Html.TextBoxFor(model => model.OrderRemark, null, new { @class = "input normal" })
                        <span class="Validform_checktip">*订单备注</span>

                    </dd>
                </dl>
                <div class="destineorderbtn">
                    @Html.Hidden("SetOrder")
                    <input type="submit" id="BtnNextOrder" value="提交"  class="btn" />
                
                </div>
            </div>
        </div>

        <div id="sideContent">
        </div>
    </div>
     
    <script>
        $(function () {  
            if ($(".ltable :radio[id='Dinecondition']:checked").val() != "undefined") {
                GetSeat($(".ltable :radio[id='Dinecondition']:checked").val()); 
            } 
            $(".ltable :radio[id='Dinecondition']").each(function () {
                $(this).click(function () {
                    GetSeat(this.value);
                });
            });
        });
        function selectTable(id, name) {
            $("#DineTable").val(id);
            $("#selectTable").html("您选择的是" + name);
        }  
        function GetSeat(dineValue) {
            var url = "@Url.Action("GetSeat")?hid=" + @Model.H_Id +"&type=" + encodeURIComponent(dineValue);
           var dine = dineValue;
           $.ajax({
               url: url,
               type: 'Post',
               dataType: 'json',
               success: function (result) { 
                   if (result == null)
                       return;
                   $("#seatUl").empty();
                   $.each(result.Data, function (index, row) {

                       var ss = "";
                       if (row.Id == $("#DineTable").val()) {
                           ss = "checked";
                       } 
                       row.s = ss;
                       var template = $('#SeatTemplate').html(); //获取模版的html
                      
                       var bookData = Mustache.render(template, row);//把每行的数据填充到模版得到html内容
                       $("#seatUl").append(bookData);
                   });
               }
           });
        }
        
        $("#OrderForm").Validform({
            datatype: {
                "time": function (gets, obj, curform, regxp) {

                    alert(gets);
                    /*参数gets是获取到的表单元素值，
                      obj为当前表单元素，
                      curform为当前验证的表单，
                      regxp为内置的一些正则表达式的引用。*/
/*
                    var reg1 = regxp["m"],
                        reg2 = /[\d]{7}/,
                        mobile = curform.find(".mobile");

                    if (reg1.test(mobile.val())) { return true; }
                    if (reg2.test(gets)) { return true; }

                    return false;*/
                }
            },
            ajaxPost: true
        });

    </script>
 
        
}










